package com.example.forjava.service;

import com.example.forjava.exception.OneException;
import com.example.forjava.exception.TwoException;
import com.example.forjava.util.GenericJsonResult;
import org.springframework.stereotype.Service;

@Service
public class ExecuteResultService {

    public GenericJsonResult validate()  {
        double random = Math.random();
        if (random > 0.5) {
        return GenericJsonResult.success();
        } else {
            throw new OneException("one error");
        }
    }

    public GenericJsonResult doStep()  {
        double random = Math.random();
        if (random > 0.5) {
            return GenericJsonResult.success();
        } else {
            throw new TwoException("two error");
        }
    }
}
